package cs2114.alarmclock;

import student.TestCase;

/**
 * // -------------------------------------------------------------------------
/**
 *  Test cases for the {@link Link} Class.
 *
 *  @author Joe Acanfora
 *  @version Nov 13, 2011
 */
public class LinkTest extends TestCase
{
    private Link<String> linkA;
    private Link<String> linkB;
    private Link<String> linkC;
    private Link<String> linkD;
    //-----Constructor------------------------
    /**
     * Constructor
     */
    public LinkTest()
    {
     // The constructor is usually empty in unit tests, since it runs
     // once for the whole class, not once for each test method.
     // Per-test initialization should be placed in setUp() instead.
    }
    /**
     * Instaniates all variables.
     */
    public void setUp()
    {
        linkA = new Link<String>("A");
        linkB = new Link<String>("B");
        linkC = new Link<String>("C");
        linkD = new Link<String>("D");
    }
    /**
     * Tests the {@link Link#join(Link)} method.
     */
    public void testJoin()
    {
        assertEquals(linkA, linkA.join(linkB));
        linkB.join(linkC);
        linkC.join(linkD);
        assertEquals(linkA.next(), linkB);
        assertEquals(linkB.next(), linkC);
    }
    /**
     * Tests the {@link Link#split()} method.
     */
    public void testSplit()
    {
        linkA.join(linkB);
        assertEquals(linkA.split(), linkB);
        linkA.join(linkC);
        linkA.split();
        assertNull(linkA.next());
    }
    /**
     * Tests the {@link Link#setData(Object)} method,
     * and
     * the {@link Link#getData()} method.
     */
    public void testtData()
    {
        assertEquals(linkA.getData(), "A");
        linkA.setData("newData");
        assertEquals(linkA.getData(), "newData");
    }


}
